<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.wxtf.platform.plugins.user.*"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	UserBean user = (UserBean)request.getSession().getAttribute("userBean");
	String _db = user.getDbType();
	String org_id = user.getCurOrgId();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>"/>
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta http-equiv="pragma" content="no-cache"/>
		<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="expires" content="0"/>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>药具库存管理</title>

		<link type="text/css" rel="stylesheet" href="ligerUI/skins/Aqua/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/<%=user.getUserCss()%>/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/ligerui-icons.css" />
		<link type="text/css" rel="stylesheet" href="resource/css/style.css" />

		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="ligerUI/js/core/base.js"></script>
		<script type="text/javascript" src="ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/validata.js"></script>

		<script type="text/javascript" src="ligerUI/js/plugins/ligerGrid.js"></script>
		<script type="text/javascript" src="ligerUI/jquery-validation/jquery.validate.min.js" ></script> 
    	<script type="text/javascript" src="ligerUI/jquery-validation/jquery.metadata.js"></script>
    	<script type="text/javascript" src="ligerUI/jquery-validation/messages_cn.js" ></script>
		
<script type="text/javascript">
var _db = '<%=_db%>';
var org_id = '<%=org_id%>';

_jsonObj.classname = "com.wxtf.platform.main.contraceptives.TmaStoreCheckDetailAction";
_jsonObj.methodname = "selectKuCun";

var manager;
$(function(){
	manager = $("#grid").ligerGrid({
		url: _url, parms: _jsonObj, width: '100%', height: '100%',
		usePager: false, rownumbers: true, alternatingRow: true, async:false, checkbox: true,totalRender: f_totalRender,heightDiff:-10,showTitle: false,
		columns: [
			{ display: '药具种类', name: 'tmgd_name', width: 120, align: 'left' ,type: 'string'},
			{ display: '药品名称', name: 'tmad_name', width: 120, align: 'left',type: 'string',render: function(record, index, value, oth){
					return "<a href='javascript:yaopinming(" + JSON.stringify(record) + ")'>"+value+"</a>";
				}
			},			
			{ display: '生产厂家', name: 'tmad_company_name', width: 100, align: 'left' ,type: 'string'},
			{ display: '批号', name: 'tmad_batch_code', width: 100, align: 'left' ,type: 'string'},
			{ display: '保质期', name: 'tmad_qgp', width: 1, hide:true, align: 'left' ,type: 'string'},
			{ display: '状态', name: 'tmad_status', width: 100, align: 'left' ,type: 'string',render: function(record, index, value, oth){
					if(value=="0"){
						return "启用";
					}else if(value=="1"){
						return "停用";
					}
				}
			},
			{ display: '价格', name: 'tmad_price', width: 100, align: 'left' ,type: 'float'},
			{ display: '数量', name: 'num', width: 100, align: 'left', type: 'int'},
			{ display: '金额', name: 'money', width: 100, align: 'left', type: 'float'}
		]
	});	
	//药品出库入库
	TmaStoreCheckMainleixing = $("#TmaStoreCheckMainleixing-grid").ligerGrid({
		url: _url, width: '540', height:'325',enabledSort:false,async:false,delayLoad:true,pageSize:100,
		usePager: true, rownumbers: true, alternatingRow: true, enabledEdit: true, groupColumnName:'t_type',
		columns: [
			{ display: 't_type', name: 't_type', hide: true, width: 1 },
			{ display: '药品名称', name: 'tmad_name', width: 100, align: 'left' },			
			{ display: '生产厂家', name: 'tmad_company_name', width: 100, align: 'left' },
			{ display: '数量', name: 'num', width: 60, align: 'left'},
			{ display: '办理人', name: 'create_by', width: 70, align: 'left' },
			{ display: '办理时间', name: 'create_time', width: 100, align: 'left' },
			{ display: '类型', name: 'leixing', width: 50, align: 'left'}
		]	
	});
});
function f_totalRender(data, currentPageData)
{
	var sum = 0.00;
	$.each(data.Rows,function(i,item){
		sum = sum + parseFloat(item.money);		
	});
	return "总金额:"+formatCurrency(sum); 
}
//药品名
function yaopinming(record){
	initWindowByDiv2('TmaStoreCheckMainleixingdiv-div', '药品查看', 565, 395, closeWin);
	var param = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaStoreCheckDetailAction",
		"methodname": "selectTmaDictionaryByTmadName",
		"logicdata": [],
		"extenddata": []
	};
	param.logicdata = "[{\"tmad_name\":\""+record.tmad_name+"\",\"org_id\":\""+org_id+"\"}]";
	TmaStoreCheckMainleixing.setOptions({url:_url,parms: param});
}
function formatCurrency(num)
        {
            if (!num) return "0.00";
            num = num.toString().replace(/\$|\,/g, '');
            if (isNaN(num))
                num = "0.00";
            sign = (num == (num = Math.abs(num)));
            num = Math.floor(num * 100 + 0.50000000001);
            cents = num % 100;
            num = Math.floor(num / 100).toString();
            if (cents < 10)
                cents = "0" + cents;
            for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
                num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));
            return (((sign) ? '' : '-') + '' + num + '.' + cents);
        }
</script>
</head>
	<body>
		<div id="TmaStoreCheckMainleixingdiv-div" style="display: none;">
			<div id="TmaStoreCheckMainleixing-grid"></div>
		</div>
		<div id="grid"></div>
	</body>
</html>